typedef struct TreeNode BTNode;
struct TreeNode* buildTree(int* preorder, int preorderSize, int* inorder, int inorderSize) {
    BTNode *root;
    int *p;
    int k;
    if(preorderSize <= 0 || inorderSize <= 0) return NULL;
    root=(BTNode*)malloc(sizeof(BTNode));
    root->val=*preorder;//头节点赋值
    for(p=inorder; p<inorder+inorderSize ; p++)
    {
        if(*p == *preorder) break;
    }
    k=p-inorder;
    root->left=buildTree(preorder+1,k,inorder,k);
    root->right=buildTree(preorder+k+1,preorderSize-k-1,p+1,inorderSize-k-1);
    return root;

}